#include <stdio.h>
#include <conio.h>

int seed;

unsigned int rnd(void){
  unsigned int hi,lo;
  lo=16807*(seed & 0xFFFF);
  hi=16807*(seed >> 16);
  lo+=(hi & 0x7FFF)<<16;
  lo+=hi>>15;
  if(lo>0x7FFFFFFF) lo-=0x7FFFFFFF;
  return seed=(int)lo;
}

int main(void){
  int k,i,j,v=0;
  seed=1;
  i=rnd();
  do{
    v++;
    j=rnd();
    if(v%10000000==0) printf("%d\n",v);
  }while(i!=j);
  printf("%d ",v);
  getch();
}
